function [ SigOut ] = OCDMmod( SigIn, NIDFNT )
%   inverse distrete fresnel transform反变换，用于OCDM调制(类似OFDM的ifft调制矩阵)

NumberSymbol = size(SigIn, 2); %列数，信息符号数

if nargin == 1
    N = 2;
    while N < size(SigIn, 1)
        N = N * 2;
    end
    NIDFNT = N;
elseif nargin == 2
    N = ceil(size(SigIn, 1)/ NIDFNT) * NIDFNT; 
end
L = N - size(SigIn, 1);
SigIn = [SigIn; zeros(L, NumberSymbol)]; %补零

Phi_1 = zeros(NIDFNT, NIDFNT);
Phi_2 = zeros(NIDFNT, NIDFNT);
for m = 0 : NIDFNT-1
    Phi_1(m+1, m+1) = exp(-1i* pi/4)*exp(1i*(pi/NIDFNT)*m^2);
    Phi_2(m+1, m+1) = exp(1i*(pi/NIDFNT)*m^2);
end

SigOut = zeros(size(SigIn));
for m = 1 : NumberSymbol
    for n = 1 : ceil(size(SigIn, 1)/ NIDFNT)
        SigOut((n-1)*NIDFNT + 1 : n*NIDFNT, m) = conj(Phi_2) * SigIn((n-1)*NIDFNT + 1 : n*NIDFNT, m);
        SigOut((n-1)*NIDFNT + 1 : n*NIDFNT, m) = sqrt(NIDFNT) * ifft(SigOut((n-1)*NIDFNT + 1 : n*NIDFNT, m), NIDFNT);
        SigOut((n-1)*NIDFNT + 1 : n*NIDFNT, m) = conj(Phi_1) * SigOut((n-1)*NIDFNT + 1 : n*NIDFNT, m);
    end
end
end
